<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>

<body>
<button class="get">get</button>
<button class="post">post</button>
</body>
</html>
<script src="https://unpkg.com/axios/dist/axios.min.js"></script>

<script>
    const get=document.querySelector('.get')
    get.addEventListener('click',()=>{
        axios({
            url:"http://127.0.0.1/api/get?name=zs&age=10",
            method:'GET',
        }).then((res)=> {
            console.log(res.data);
        })
    })

    const post=document.querySelector('.post')
    post.addEventListener('click',()=>{
        axios({
            url:"http://127.0.0.1/api/post",
            method:'POST',
            data:{
                name:'zs',
                age:18
            }
        }).then((res)=> {
            console.log(res.data);
        })
    })


</script>